#ifndef MY_INC_APP_APP_INIT_H_
#define MY_INC_APP_APP_INIT_H_

#include <MY_INC/LC/LC_SYS.h>
void                   System_Init(void);
void                   Loop_Init(LoopParameter *loopparam);
void                   Loop_Reset(LoopParameter *loopparam);
extern PR_Diff_Typedef PR_50Hz_Inv_I;
extern PR_Diff_Typedef PR_150Hz_Inv_I;
extern PR_Diff_Typedef PR_250Hz_Inv_I;

extern PR_Diff_Typedef PR_50Hz_Rec_I;
extern PR_Diff_Typedef PR_150Hz_Rec_I;
extern PR_Diff_Typedef PR_250Hz_Rec_I;
extern PR_Diff_Typedef PR_50Hz_Rec_V;
extern PR_Diff_Typedef PR_150Hz_Rec_V;
extern PR_Diff_Typedef PR_250Hz_Rec_V;

/*功率环路*/
extern VariableStep_Typedef   Power_Pe_Rec; // 电流参考变步长补偿
extern VariableStep_Typedef   Power_Qe_Rec; // 电流参考变步长补偿
extern AntiWindupPID__Typedef PI_Power_Pe;  // 电压PI
extern AntiWindupPID__Typedef PI_Power_Qe;  // 电压PI

/***锁相环****/
extern PLL_Typedef PLL_Inv;
extern PLL_Typedef PLL_Rec;
/*****单相变换*****/
extern TOGI_Typedef TOGI_VGrid_Inv; // TOGI变换
extern TOGI_Typedef TOGI_VGrid_Rec; // TOGI变换
extern TOGI_Typedef TOGI_IL_Rec;    // TOGI变换
/******变步长******/
extern VariableStep_Typedef PR_IREF_Inv; // 电流参考变步长补偿
extern VariableStep_Typedef PR_VREF_Inv; // 电压参考变步长补偿
extern VariableStep_Typedef PR_IREF_Rec; // 电流参考变步长补偿
extern VariableStep_Typedef PR_VREF_Rec; // 电流参考变步长补偿

// extern IncrementalPID_Typedef  PI_Udc_Inv; // 电压PI
extern AntiWindupPID__Typedef  PI_Udc_Inv; // 电压PI
extern FilterTrap_Typedef      FilterTrap_Udc;
extern SignalAnalysisr_Typedef SignalAnalysisr_Inv;
extern SignalAnalysisr_Typedef SignalAnalysisr_Rec_v;
extern SignalAnalysisr_Typedef SignalAnalysisr_Rec_i;
extern PQ_Typedef              PQ_Rec;
static inline void             Pwm_Enable(Pwm *Pwm) // PWM使能
{
    // 更好的命名惯例：PwmControl 是类型名，PwmControl_ptr 是指向该类型变量的指针
    LL_HRTIM_TIM_SetCompare1(HRTIM1, Pwm->timer[0], 0);
    LL_HRTIM_TIM_SetCompare1(HRTIM1, Pwm->timer[1], 0);
    LL_HRTIM_EnableOutput(HRTIM1, Pwm->output_p[0] | Pwm->output_n[0] | Pwm->output_p[1] | Pwm->output_n[1]);
}
static inline void Pwm_Disable(Pwm *Pwm) // PWM失能
{
    // 更好的命名惯例：PwmControl 是类型名，PwmControl_ptr 是指向该类型变量的指针
    LL_HRTIM_DisableOutput(HRTIM1, Pwm->output_p[0] | Pwm->output_n[0] | Pwm->output_p[1] | Pwm->output_n[1]);
    LL_HRTIM_TIM_SetCompare1(HRTIM1, Pwm->timer[0], 0);
    LL_HRTIM_TIM_SetCompare1(HRTIM1, Pwm->timer[1], 0);
    Pwm->pwm_en_flag = Nonactivated;
    Pwm->pwm_flag = Nonactivated; // 设置为已激活状态
}
#endif // !MY_INC_APP_APP_INIT_H_
